package com.controllers;


import com.alibaba.fastjson.JSONObject;
import com.config.exception.MyException;
import com.controllers.forms.SimpleResponse;
import com.services.interfaces.ITestService;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;


/**
 * Created by Administrator on 2017/5/9.
 */
@Controller
@RequestMapping("/api/test")
public class TestController {




    @RequestMapping(value = {"/test1"}, method = {RequestMethod.POST})
    public
    @ResponseBody
    JSONObject getUserList(HttpServletRequest request) throws Exception {
//        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
//        Client client = dcf.createClient("http://localhost:9091/soap/user?wsdl");
//        Object[] objects = client.invoke("sayHello", "test");
//        System.out.println(objects[0].toString());
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://221.224.63.242:8888/Platform/Communicate.asmx");
        Object[] objects = client.invoke("TransformData", "test");
        System.out.println(objects[0].toString());

        return SimpleResponse.ok("");
    }


    @RequestMapping(value = {"/unitTest"}, method = {RequestMethod.POST})
    public
    @ResponseBody
    JSONObject unitTest(HttpServletRequest request) throws MyException {
        System.out.println("------");
        return SimpleResponse.ok("");
    }


}
